# 2010-08-08, Matthew C. Cluver, matthew.cluver@gmail.com
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted.
#  
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

/*
== Class: openvz

This class is used to setup a working OpenVZ host node. It will attempt 
to initially install the necessary OpenVZ Kernel, Quota & Tools Packages 
on your host machine. Currently Debian has been the only tested OS for
this module, though it should work on Ubuntu as well.

The default paths defined below may need to be adjusted for your local
system/cluster configuration. 

See also:
- openvz::vzctl

Usage:
  include openvz

Note: If your host does not already have the OpenVZ Kernel and is unable to 
install the OpenVZ Kernel through the package resource type for Puppet you 
will not be able to use this module.

*/

import "defines/*.pp"
import "classes/*.pp"

class openvz {

	case $operatingsystem {
		debian: { include openvz::debian }
		ubuntu: { include openvz::ubuntu }
		fedora: { include openvz::fedora }
	}
	
}

class openvz::debian {
	package {
		[ "linux-image-openvz-686", "vzctl", "vzquota", "vzdump" ]:
		ensure => installed,
    	}    	
    	
}

class openvz::ubuntu {
	package {
		[ "linux-openvz", "vzctl" ]:
		ensure => installed,
	}
}

class openvz::fedora {
	package {
		[ "ovzkernel", "vzctl", "vzquota" ]:
		ensure => installed,
	}

	  service { ["vz"]:
	  	    ensure	   => running,
	    	enable     => true,
	    	hasstatus  => true,
	    	hasrestart => true,
	   		require    => [Package["vz"]],
	  }  
}
 	

